import 'package:flutter/material.dart';
import '../data/CustomData.dart';

class MovieScroll extends StatelessWidget {
  final List infoList = new CustomData().infoList;
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 260,
      child: ListView.builder(
        scrollDirection: Axis.horizontal,
        itemCount: infoList.length,
        itemBuilder: (BuildContext context, int index) {
          return ScrollItem(item: infoList[index]);
        },
      ),
    );
  }
}

class ScrollItem extends StatelessWidget {
  ScrollItem({Key key, @required this.item}) : super(key: key);
  final Map item;
  @override
  Widget build(BuildContext context) {
    return Container(
      width: 137.5,
      padding: EdgeInsets.only(left: 5, right: 5),
      child: Column(
        children: <Widget>[
          //图片
          Image(
              height: 178.5,
              width: 127.5,
              fit: BoxFit.cover,
              image: NetworkImage('${item["img"]}')),
          //电影名字-nm
          Text('${item["nm"]}'),
          //电影的描述-star
          Text(
            '${item["star"]}',
            //文字溢出点点点
            overflow: TextOverflow.ellipsis,
            maxLines: 2,
            style: TextStyle(color: Colors.grey),
          ),
        ],
      ),
    );
  }
}
